package Month11.Day8;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.Callable;

public class Company {
    private String name;//公司名称
    private String adress;//地址
    private String phone;//电话
    private String natureOfBusiness;//经营范围

    public Company(String name, String adress, String phone, String natureOfBusiness) {
        this.name = name;
        this.adress = adress;
        this.phone = phone;
        this.natureOfBusiness = natureOfBusiness;
    }

    public void show() {
        System.out.println("这是个" + name + "公司，电话是" + phone + ",地址是在" + adress + ",经营的范围是" + natureOfBusiness);
    }

    /*
    招聘
     */
    List<Staff> list = new ArrayList<Staff>();

    public void recruit() {
        Staff s1 = new Staff("亚索", 20, "男", "中单", 300, "22");
        Staff s2 = new Staff("瑞文", 21, "女", "上单", 400, "22");
        Staff s3 = new Staff("锤石", 22, "男", "辅助", 500, "22");
        list.add(s1);
        list.add(s2);
        list.add(s3);
        for (int i = 0; i < list.size() - 1; i++) {
            for (int j = i + 1; j < list.size(); j++) {
                if (list.get(i).getJobNumber().equals(list.get(j).getJobNumber())) {
                    System.out.println("第" + (i + 1) + "个员工和第" + (j + 1) + "个员工工号相同");
                    Scanner in = new Scanner(System.in);
                    System.out.println("请输入新的工号");
                    String newJobNumber = in.next();
                    list.get(i).setJobNumber(newJobNumber);
                    continue;
                }
            }
        }
        for (Staff staff : list)
            System.out.println(staff);


    }

    /*
    辞退员工
     */
    public void retireStaff() {
        Scanner in = new Scanner(System.in);
        System.out.println("请输入你要辞退员工的工号");
        String jobNumber1 = in.next();
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).getJobNumber().equals(jobNumber1)) {
                list.remove(i);
            }
        }
        for (Staff staff : list)
            System.out.println(staff);


    }

    /*
    统计人数；
     */
    public void staffCount() {
        System.out.println("公司现在的人数为" + list.size() + "人");

    }

    /*
    获得公司薪水最高的员工
     */
    int temp = 0;
    String s;
    public void maxSalary() {
        System.out.println(list.size());
        for (int i = 0; i < list.size(); i++) {
            if (temp < list.get(i).getSalary()) {
                temp = list.get(i).getSalary();
                s = list.get(i).getJobNumber();
            }

        }
        System.out.println("公司薪水最高的人是工号为" + s +
                "的员工，薪水为" + temp + "元");
    }
    /*
    是否加入新员工
     */


    public void newStaff(){
        while (true){
            Scanner in=new Scanner(System.in);
            System.out.println("请输入是否需要新员工,1:需要,2:不需要，输出现有员工信息");
            int choice=in.nextInt();
            if (choice==1){
                System.out.println("请输入姓名");
                String name=in.next();
                System.out.println("请输入年龄");
                int age=in.nextInt();
                System.out.println("请输入性别");
                String sex=in.next();
                System.out.println("请输入职位");
                String post=in.next();
                System.out.println("请输入薪水");
                int salary=in.nextInt();
                System.out.println("请输入工号");
                String jobNumber=in.next();
                Staff s=new Staff();
                s.setName(name);
                s.setJobNumber(jobNumber);
                s.setAge(age);
                s.setPost(post);
                s.setSalary(salary);
                s.setSex(sex);
                list.add(s);
                System.out.println(s);
            }else if (choice==2){
                for (Staff st:list)
                    System.out.println(st);
                return;
            }


        }



    }


}
